/* DOCUMENT READY */

$(document).ready(function(){
	imagePreview();
	tooltip();
	/*$('.editor').wysiwyg(
			{
				controls : {
				separator01 : { visible : true },
				separator00 : { visible : true },
				insertOrderedList : { visible : true },
				insertUnorderedList : { visible : true },
				justifyLeft: { visible : true },
				justifyCenter: { visible : true },
				justifyRight: { visible : true },
				justifyFull: { visible : true },
				underline: { visible : true }
			}	}	
	);*/

	$(".datepicker").mask("99.99.9999");
	$(".saat").mask("99:99");
	$(".tarih").datepicker($.extend({}, 
			$.datepicker.regional["tr"], { 
				yearRange: "-80:+0", 
    			showStatus: true, 
    			showOn: "both", 
   				buttonImage: "images/calendar.png", 
   				buttonImageOnly: true 
		}));
		




	$(".secret").hide();
	$('.passer').each(function() {
		
		$(this).bind (
			"click",
			function(){
				$(this).next().show();
			}
		);
	  
	});
	
	$('#dt_example').dataTable();
	$('.validate').validate();
	
});

$.extend($.validator.messages, {
required: "Information is required",
email: "Email is required",
equalTo: "Password is not Correct ",
number: "Number is required"
});

tinyMCE.init({

// General options
	mode : "specific_textareas",
	theme : "advanced",
	editor_selector : /(mceEditor|mceRichText)/,

	
 
forced_root_block : "" ,
force_br_newlines : "true",
force_p_newlines : "false",
height: "300",


	plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
file_browser_callback : "tinyBrowser",
	// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true
});





/* TOOLTIP FUNCTION */

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

/* IMAGE PREVIEW FUNCTION */
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

/* ENABLE/DISABLE CALENDER FIELD */
function toggleCalendar()
{
	if ($('#hmn').is(':checked')) {
		$('.tarih').attr("disabled", true);
		$('#ys').attr("disabled", true);  
	}
	else{
		$('.tarih').removeAttr("disabled");
		$('#ys').removeAttr("disabled");  
	}
}